package com.example.library_demo.controller;


import com.example.library_demo.annotation.Auth;
import com.example.library_demo.common.Result;
import com.example.library_demo.dto.recharge.RechargeDTO;
import com.example.library_demo.entity.User;
import com.example.library_demo.enums.GlobalResponseResultEnum;
import com.example.library_demo.service.ICardService;
import com.example.library_demo.service.IRechargeService;
import com.example.library_demo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Eric
 * @since 2024-11-28
 */
@RestController
@RequestMapping("/recharge")
public class RechargeController extends BaseController{

    @Autowired
    private IUserService userService;
    @Autowired
    private ICardService cardService;
    @Autowired
    private IRechargeService rechargeService;


    @Auth
    @PostMapping("/top-up")
    public Result topUp(@RequestBody RechargeDTO rechargeDTO) {
        User user = super.getCurrentUser();
        rechargeService.topUp(rechargeDTO, user.getUserId());
        return Result.success(GlobalResponseResultEnum.SUCCESS.getCode(),
                "Top up [" + rechargeDTO.getTopUpMoney() + "] success~~~");
    }

}

